package com.ibeeking.found.cop.b.rest.controller.v1;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ibeeking.found.cop.b.rest.service.IMsgGroupMassMessageService;
import com.ibeeking.found.cop.b.rest.service.IMsgMessageTaskService;
import com.ibeeking.found.cop.service.common.param.MsgMassMessageParam;
import com.ibeeking.found.cop.service.common.query.MsgMassMessagePageQuery;
import com.ibeeking.found.cop.service.common.query.MsgMassMessageQuery;
import com.ibeeking.found.cop.service.common.vo.MsgMassMessageVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName MsgGroupMassMessageController
 * @Description
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/b/msgGroupMassMessage/v1")
public class MsgGroupMassMessageController {

    @Resource
    private IMsgGroupMassMessageService msgGroupMassMessageServiceImpl;

    @Resource
    private IMsgMessageTaskService msgMassMessageTaskServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询客户群群发消息列表")
    @PostMapping(value = "/list")
    public List<MsgMassMessageVO> list(@RequestBody MsgMassMessageQuery query) {
        return msgGroupMassMessageServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询客户群群发消息分页列表")
    @PostMapping(value = "/pageList")
    public Page<MsgMassMessageVO> pageList(@RequestBody MsgMassMessagePageQuery pageQuery) {
        return msgGroupMassMessageServiceImpl.pageList(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加客户群群发消息")
    @PostMapping(value = "/add")
    public Boolean add(@RequestBody @Validated(BaseValidationGroup.Insert.class) MsgMassMessageParam param) {
        return msgGroupMassMessageServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改客户群群发消息")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated(BaseValidationGroup.Update.class) MsgMassMessageParam param) {
        return msgGroupMassMessageServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "修改客户群群发消息")
    @PostMapping(value = "/copy/{id}")
    public Boolean copy(@PathVariable("id") Long id) {
        return msgGroupMassMessageServiceImpl.copy(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改是否启用")
    @GetMapping(value = "/changeStatus/{id}/{status}")
    public Boolean changeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return msgGroupMassMessageServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看客户群群发消息详情")
    @GetMapping(value = "/view/{id}")
    public MsgMassMessageVO view(@PathVariable("id") Long id) {
        return msgGroupMassMessageServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除客户群群发消息")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return msgGroupMassMessageServiceImpl.del(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "发送客户群群发消息")
    @PostMapping(value = "/sendWxCpGroupMassMessage/{id}")
    public Boolean sendWxCpGroupMassMessage(@PathVariable("id") Long id) {
        return msgGroupMassMessageServiceImpl.sendWxCpGroupMassMessage(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "发送客户群群发消息")
    @PostMapping(value = "/notifyWxCpSender/{id}")
    public Boolean notifyWxCpSender(@PathVariable("id") Long id) {
        return msgMassMessageTaskServiceImpl.sendMessageNotify(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "取消发送客户群群发消息")
    @PostMapping(value = "/stopWxCpGroupMassMessage/{id}")
    public Boolean stopWxCpGroupMassMessage(@PathVariable("id") Long id) {
        return msgGroupMassMessageServiceImpl.stopWxCpGroupMassMessage(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "刷新客户群发消息记录")
    @PostMapping(value = "/refreshWxCpGroupMassMessageSendRecord")
    public Boolean refreshWxCpGroupMassMessageSendRecord() {
        return msgGroupMassMessageServiceImpl.refreshWxCpGroupMassMessageSendRecord();
    }

}
